package com.example.demo.system.controller;

import com.example.demo.system.entity.RolePermission;
import com.example.demo.system.service.RolePermissionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class RolePermissionController {

    @Autowired
    private RolePermissionService rolePermissionService;

    @GetMapping("/role-permission")
    @ApiOperation("RolePermission查询单个")
    public ResultVO getRolePermission(@RequestBody RolePermission rolePermission){
     ResultVO resultVO = rolePermissionService.getRolePermission(RolePermission rolePermission);
     return  resultVO;
   }

    @GetMapping("/role-permission")
    @ApiOperation("RolePermission查询全部")
    public ResultVO getAllRolePermission(){
        ResultVO resultVO = rolePermissionService.getAllRolePermission();
        return  resultVO;
    }

    @PostMapping("/role-permission")
    @ApiOperation("RolePermission新增")
    public ResultVO add(@Valid @RequestBody RolePermission rolePermission) {
        ResultVO resultVO = rolePermissionService.add(RolePermission rolePermission);
        return  resultVO;
    }

    @PutMapping("/role-permission")
    @ApiOperation("RolePermission修改")
    public ResultVO update(@Valid @RequestBody RolePermission rolePermission) {
        ResultVO resultVO = rolePermissionService.update(RolePermission rolePermission);
        returnresultVO;
    }


    @DeleteMapping(value = "/role-permission/{ids}")
    @ApiOperation("RolePermission删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = rolePermissionService.remove(String ids);
        return resultVO;
    }
}
